package cn.edu.sdjzu.xg.eagle.service.impl;

import cn.edu.sdjzu.xg.eagle.entities.Teacher;
import cn.edu.sdjzu.xg.eagle.mapper.TeacherMapper;
import cn.edu.sdjzu.xg.eagle.service.inface.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

@Service
public class TeacherImpl implements TeacherService {

    @Autowired
    private TeacherMapper teacherMapper;

    @Override
    public String addTeacher(Teacher teacher) throws SQLException {
        return teacherMapper.addTeacher(teacher) ? "添加成功" : "添加失败";
    }

    @Override
    public String deleteTeacher(Integer id) throws SQLException {
        return teacherMapper.deleteTeacher(id) ? "删除成功" : "删除失败";
    }

    @Override
    public String updateTeacher(Teacher teacher) throws SQLException {
        return teacherMapper.updateTeacher(teacher) ?  "修改成功" : "修改失败";
    }

    @Override
    public Teacher getTeacher(Integer id) throws SQLException {
        return teacherMapper.getTeacher(id);
    }

    @Override
    public List<Teacher> getTeachers() throws SQLException {
        return teacherMapper.getTeachers();
    }
}